#include "tile/tile.hpp"

#include "graphics.hpp"

namespace nmc
{
	Tile::Tile()
	{

	}

	Tile::Tile(Type type, const Point& tileMapPosition, TileMap* tileMap)
		:mType(type),
		mTileMapPosition(tileMapPosition),
		mTileMap(tileMap),
        mCollisionChecked(false)
	{}

	Tile::Type Tile::getType() const
	{
		return mType;
	}

	Tile::Layer Tile::getLayer() const
	{
		return mLayer;
	}

	void Tile::setLayer(Tile::Layer layer)
	{
		mLayer = layer;
	}

	const Point& Tile::getTileMapPosition() const
	{
		return mTileMapPosition;
	}

	const Point Tile::getWorldPosition() const
	{
		Point result(mTileMapPosition.x * Tile::SIZE,
					 mTileMapPosition.y * Tile::SIZE);

		return result;
	}

	TileMap* Tile::getTileMap()
	{
		return mTileMap;
	}

	void Tile::drawSolidity(Graphics* graphics)
	{
		if (mCollisionChecked)
		{
			graphics->setBlendMode(Graphics::ALPHA);
			graphics->setColor(Color(255, 200, 0, 150));
			graphics->fillRectangle(Rectangle(getWorldPosition().x,
				                              getWorldPosition().y,
											  SIZE,
											  SIZE));
		}
	}

	void Tile::setCollisionChecked(bool checked)
	{
		mCollisionChecked = checked;
	}
}	